
<!doctype html>
<html lang="en" class="no-js">

  <!-- Mirrored from flatbuffers.dev/languages/cpp/ by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 08 May 2025 07:01:35 GMT -->
  <!-- Added by HTTrack --><meta http-equiv="content-type"
    content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
  <head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">

    <link rel="canonical" href="index.html">

    <link rel="prev" href="../c/index.html">

    <link rel="next" href="../c_sharp/index.html">

    <link rel="icon" href="../../assets/images/favicon.png">
    <meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.6.9">

    <title>C++ - FlatBuffers Docs （文档）</title>

    <link rel="stylesheet"
      href="../../assets/stylesheets/main.4af4bdda.min.css">

    <link rel="stylesheet"
      href="../../assets/stylesheets/palette.06af60db.min.css">

    <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
    <link rel="stylesheet"
      href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&amp;display=fallback">
    <style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>

    <script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>

  </head>

  <body dir="ltr" data-md-color-scheme="default" data-md-color-primary="indigo"
    data-md-color-accent="indigo">

    <input class="md-toggle" data-md-toggle="drawer" type="checkbox"
      id="__drawer" autocomplete="off">
    <input class="md-toggle" data-md-toggle="search" type="checkbox"
      id="__search" autocomplete="off">
    <label class="md-overlay" for="__drawer"></label>
    <div data-md-component="skip">

      <a href="#language-guide-c" class="md-skip">
        Skip to content
      </a>

    </div>
    <div data-md-component="announce">

    </div>

    <header class="md-header md-header--shadow" data-md-component="header">
      <nav class="md-header__inner md-grid" aria-label="Header">
        <a href="../../index.html" title="FlatBuffers Docs （文档）"
          class="md-header__button md-logo" aria-label="FlatBuffers Docs （文档）"
          data-md-component="logo">

          <img src="../../assets/flatbuffers_logo.svg" alt="logo">

        </a>
        <label class="md-header__button md-icon" for="__drawer">

          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path
              d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z" /></svg>
        </label>
        <div class="md-header__title" data-md-component="header-title">
          <div class="md-header__ellipsis">
            <div class="md-header__topic">
              <span class="md-ellipsis">
                FlatBuffers Docs （文档）
              </span>
            </div>
            <div class="md-header__topic" data-md-component="header-topic">
              <span class="md-ellipsis">

                C++

              </span>
            </div>
          </div>
        </div>

        <form class="md-header__option" data-md-component="palette">

          <input class="md-option" data-md-color-media
            data-md-color-scheme="default" data-md-color-primary="indigo"
            data-md-color-accent="indigo" aria-label="Switch to dark mode"
            type="radio" name="__palette" id="__palette_0">

          <label class="md-header__button md-icon" title="Switch to dark mode"
            for="__palette_1" hidden>
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path
                d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z" /></svg>
          </label>

          <input class="md-option" data-md-color-media
            data-md-color-scheme="slate" data-md-color-primary="indigo"
            data-md-color-accent="indigo" aria-label="Switch to light mode"
            type="radio" name="__palette" id="__palette_1">

          <label class="md-header__button md-icon" title="Switch to light mode"
            for="__palette_0" hidden>
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path
                d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z" /></svg>
          </label>

        </form>

        <script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script>

        <div class="md-header__source">
          <a href="https://github.com/google/flatbuffers"
            title="Go to repository" class="md-source"
            data-md-component="source">
            <div class="md-source__icon md-icon">

              <svg xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 496 512"><!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path
                  d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8M97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2" /></svg>
            </div>
            <div class="md-source__repository">
              google/FlatBuffers
            </div>
          </a>
        </div>

      </nav>

    </header>

    <div class="md-container" data-md-component="container">

      <main class="md-main" data-md-component="main">
        <div class="md-main__inner md-grid">

          <div class="md-sidebar md-sidebar--primary"
            data-md-component="sidebar" data-md-type="navigation">
            <div class="md-sidebar__scrollwrap">
              <div class="md-sidebar__inner">

                <nav class="md-nav md-nav--primary" aria-label="Navigation"
                  data-md-level="0">
                  <label class="md-nav__title" for="__drawer">
                    <a href="../../index.html" title="FlatBuffers Docs （文档）"
                      class="md-nav__button md-logo"
                      aria-label="FlatBuffers Docs （文档）"
                      data-md-component="logo">

                      <img src="../../assets/flatbuffers_logo.svg" alt="logo">

                    </a>
                    FlatBuffers Docs （文档）
                  </label>

                  <div class="md-nav__source">
                    <a href="https://github.com/google/flatbuffers"
                      title="Go to repository" class="md-source"
                      data-md-component="source">
                      <div class="md-source__icon md-icon">

                        <svg xmlns="http://www.w3.org/2000/svg"
                          viewBox="0 0 496 512"><!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path
                            d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8M97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2" /></svg>
                      </div>
                      <div class="md-source__repository">
                        google/FlatBuffers
                      </div>
                    </a>
                  </div>

                  <ul class="md-nav__list" data-md-scrollfix>

                    <li class="md-nav__item">
                      <a href="../../index.html" class="md-nav__link">

                        <span class="md-ellipsis">
                          Overview（概述）

                        </span>

                      </a>
                    </li>

                    <li class="md-nav__item">
                      <a href="../../quick_start/index.html"
                        class="md-nav__link">

                        <span class="md-ellipsis">
                          Quick Start（快速入门）

                        </span>

                      </a>
                    </li>

                    <li class="md-nav__item">
                      <a href="../../tutorial/index.html" class="md-nav__link">

                        <span class="md-ellipsis">
                          Tutorial（教程）

                        </span>

                      </a>
                    </li>

                    <li class="md-nav__item md-nav__item--nested">

                      <input
                        class="md-nav__toggle md-toggle md-toggle--indeterminate"
                        type="checkbox" id="__nav_4">

                      <label class="md-nav__link" for="__nav_4"
                        id="__nav_4_label" tabindex="0">

                        <span class="md-ellipsis">
                          Compiler (flatc)（编译器）

                        </span>

                        <span class="md-nav__icon md-icon"></span>
                      </label>

                      <nav class="md-nav" data-md-level="1"
                        aria-labelledby="__nav_4_label" aria-expanded="false">
                        <label class="md-nav__title" for="__nav_4">
                          <span class="md-nav__icon md-icon"></span>
                          Compiler (flatc)
                        </label>
                        <ul class="md-nav__list" data-md-scrollfix>

                          <li class="md-nav__item">
                            <a href="../../building/index.html"
                              class="md-nav__link">

                              <span class="md-ellipsis">
                                Building（构建）

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../../flatc/index.html"
                              class="md-nav__link">

                              <span class="md-ellipsis">
                                Using（使用）

                              </span>

                            </a>
                          </li>

                        </ul>
                      </nav>

                    </li>

                    <li class="md-nav__item md-nav__item--nested">

                      <input
                        class="md-nav__toggle md-toggle md-toggle--indeterminate"
                        type="checkbox" id="__nav_5">

                      <label class="md-nav__link" for="__nav_5"
                        id="__nav_5_label" tabindex="0">

                        <span class="md-ellipsis">
                          Schema (.fbs)（模式定义）

                        </span>

                        <span class="md-nav__icon md-icon"></span>
                      </label>

                      <nav class="md-nav" data-md-level="1"
                        aria-labelledby="__nav_5_label" aria-expanded="false">
                        <label class="md-nav__title" for="__nav_5">
                          <span class="md-nav__icon md-icon"></span>
                          Schema (.fbs)
                        </label>
                        <ul class="md-nav__list" data-md-scrollfix>

                          <li class="md-nav__item">
                            <a href="../../schema/index.html"
                              class="md-nav__link">

                              <span class="md-ellipsis">
                                Overview（概述）

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../../evolution/index.html"
                              class="md-nav__link">

                              <span class="md-ellipsis">
                                Evolution（演变）

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../../grammar/index.html"
                              class="md-nav__link">

                              <span class="md-ellipsis">
                                Grammar（语法）

                              </span>

                            </a>
                          </li>

                        </ul>
                      </nav>

                    </li>

                    <li
                      class="md-nav__item md-nav__item--active md-nav__item--nested">

                      <input class="md-nav__toggle md-toggle " type="checkbox"
                        id="__nav_6" checked>

                      <label class="md-nav__link" for="__nav_6"
                        id="__nav_6_label" tabindex="0">

                        <span class="md-ellipsis">
                          Language Guides（语言指南）

                        </span>

                        <span class="md-nav__icon md-icon"></span>
                      </label>

                      <nav class="md-nav" data-md-level="1"
                        aria-labelledby="__nav_6_label" aria-expanded="true">
                        <label class="md-nav__title" for="__nav_6">
                          <span class="md-nav__icon md-icon"></span>
                          Language Guides
                        </label>
                        <ul class="md-nav__list" data-md-scrollfix>

                          <li class="md-nav__item">
                            <a href="../c/index.html" class="md-nav__link">

                              <span class="md-ellipsis">
                                C

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item md-nav__item--active">

                            <input class="md-nav__toggle md-toggle"
                              type="checkbox" id="__toc">

                            <label class="md-nav__link md-nav__link--active"
                              for="__toc">

                              <span class="md-ellipsis">
                                C++

                              </span>

                              <span class="md-nav__icon md-icon"></span>
                            </label>

                            <a href="index.html"
                              class="md-nav__link md-nav__link--active">

                              <span class="md-ellipsis">
                                C++

                              </span>

                            </a>

                            <nav class="md-nav md-nav--secondary"
                              aria-label="Table of contents">

                              <label class="md-nav__title" for="__toc">
                                <span class="md-nav__icon md-icon"></span>
                                Table of contents
                              </label>
                              <ul class="md-nav__list" data-md-component="toc"
                                data-md-scrollfix>

                                <li class="md-nav__item">
                                  <a href="#before-you-get-started"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Before you get started
                                    </span>
                                  </a>

                                  <nav class="md-nav"
                                    aria-label="Before you get started">
                                    <ul class="md-nav__list">

                                      <li class="md-nav__item">
                                        <a href="#prerequisites"
                                          class="md-nav__link">
                                          <span class="md-ellipsis">
                                            Prerequisites
                                          </span>
                                        </a>

                                      </li>

                                    </ul>
                                  </nav>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#flatbuffers-c-library-code-location"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      FlatBuffers C++ library code location
                                    </span>
                                  </a>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#testing-the-flatbuffers-c-library"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Testing the FlatBuffers C++ library
                                    </span>
                                  </a>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#using-the-flatbuffers-c-library"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Using the FlatBuffers C++ library
                                    </span>
                                  </a>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#object-based-api"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Object based API
                                    </span>
                                  </a>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#external-references"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      External references
                                    </span>
                                  </a>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#using-different-pointer-types"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Using different pointer types
                                    </span>
                                  </a>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#using-different-string-type"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Using different string type
                                    </span>
                                  </a>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#reflection-resizing"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Reflection (&amp; Resizing)
                                    </span>
                                  </a>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#mini-reflection"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Mini Reflection
                                    </span>
                                  </a>

                                </li>

                                <li class="md-nav__item">
                                  <a
                                    href="#storing-maps-dictionaries-in-a-flatbuffer"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Storing maps / dictionaries in a
                                      FlatBuffer
                                    </span>
                                  </a>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#direct-memory-access"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Direct memory access
                                    </span>
                                  </a>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#access-of-untrusted-buffers"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Access of untrusted buffers
                                    </span>
                                  </a>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#text-schema-parsing"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Text &amp; schema parsing
                                    </span>
                                  </a>

                                  <nav class="md-nav"
                                    aria-label="Text &amp; schema parsing">
                                    <ul class="md-nav__list">

                                      <li class="md-nav__item">
                                        <a
                                          href="#using-the-compiler-as-a-conversion-tool"
                                          class="md-nav__link">
                                          <span class="md-ellipsis">
                                            Using the compiler as a conversion
                                            tool
                                          </span>
                                        </a>

                                      </li>

                                      <li class="md-nav__item">
                                        <a
                                          href="#making-your-program-capable-of-loading-text-directly"
                                          class="md-nav__link">
                                          <span class="md-ellipsis">
                                            Making your program capable of
                                            loading text directly
                                          </span>
                                        </a>

                                      </li>

                                    </ul>
                                  </nav>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#threading" class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Threading
                                    </span>
                                  </a>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#advanced-union-features"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Advanced union features
                                    </span>
                                  </a>

                                </li>

                                <li class="md-nav__item">
                                  <a
                                    href="#depth-limit-of-nested-objects-and-stack-overflow-control"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Depth limit of nested objects and
                                      stack-overflow control
                                    </span>
                                  </a>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#flatbuffers_locale_cpp"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Dependence from C-locale
                                    </span>
                                  </a>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#support-of-floating-point-numbers"
                                    class="md-nav__link">
                                    <span class="md-ellipsis">
                                      Support of floating-point numbers
                                    </span>
                                  </a>

                                  <nav class="md-nav"
                                    aria-label="Support of floating-point numbers">
                                    <ul class="md-nav__list">

                                      <li class="md-nav__item">
                                        <a
                                          href="#support-of-hexadecimal-and-special-floating-point-numbers"
                                          class="md-nav__link">
                                          <span class="md-ellipsis">
                                            Support of hexadecimal and special
                                            floating-point numbers
                                          </span>
                                        </a>

                                      </li>

                                      <li class="md-nav__item">
                                        <a
                                          href="#comparison-of-floating-point-nan-values"
                                          class="md-nav__link">
                                          <span class="md-ellipsis">
                                            Comparison of floating-point NaN
                                            values
                                          </span>
                                        </a>

                                      </li>

                                    </ul>
                                  </nav>

                                </li>

                                <li class="md-nav__item">
                                  <a href="#grpc" class="md-nav__link">
                                    <span class="md-ellipsis">
                                      gRPC
                                    </span>
                                  </a>

                                  <nav class="md-nav" aria-label="gRPC">
                                    <ul class="md-nav__list">

                                      <li class="md-nav__item">
                                        <a href="#before-you-get-started_1"
                                          class="md-nav__link">
                                          <span class="md-ellipsis">
                                            Before you get started
                                          </span>
                                        </a>

                                      </li>

                                      <li class="md-nav__item">
                                        <a
                                          href="#using-the-flatbuffers-grpc-c-library"
                                          class="md-nav__link">
                                          <span class="md-ellipsis">
                                            Using the FlatBuffers gRPC C++
                                            library
                                          </span>
                                        </a>

                                      </li>

                                    </ul>
                                  </nav>

                                </li>

                              </ul>

                            </nav>

                          </li>

                          <li class="md-nav__item">
                            <a href="../c_sharp/index.html"
                              class="md-nav__link">

                              <span class="md-ellipsis">
                                C#

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../dart/index.html" class="md-nav__link">

                              <span class="md-ellipsis">
                                Dart

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../go/index.html" class="md-nav__link">

                              <span class="md-ellipsis">
                                Go

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../java/index.html" class="md-nav__link">

                              <span class="md-ellipsis">
                                Java

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../javascript/index.html"
                              class="md-nav__link">

                              <span class="md-ellipsis">
                                JavasScript

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../kotlin/index.html" class="md-nav__link">

                              <span class="md-ellipsis">
                                Kotlin

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../lobster/index.html"
                              class="md-nav__link">

                              <span class="md-ellipsis">
                                Lobster

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../lua/index.html" class="md-nav__link">

                              <span class="md-ellipsis">
                                Lua

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../php/index.html" class="md-nav__link">

                              <span class="md-ellipsis">
                                PHP

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../python/index.html" class="md-nav__link">

                              <span class="md-ellipsis">
                                Python

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../rust/index.html" class="md-nav__link">

                              <span class="md-ellipsis">
                                Rust

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../swift/index.html" class="md-nav__link">

                              <span class="md-ellipsis">
                                Swift

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../typescript/index.html"
                              class="md-nav__link">

                              <span class="md-ellipsis">
                                TypeScript

                              </span>

                            </a>
                          </li>

                        </ul>
                      </nav>

                    </li>

                    <li class="md-nav__item">
                      <a href="../../support/index.html" class="md-nav__link">

                        <span class="md-ellipsis">
                          Supported Configurations（支持的配置）

                        </span>

                      </a>
                    </li>

                    <li class="md-nav__item">
                      <a href="../../white_paper/index.html"
                        class="md-nav__link">

                        <span class="md-ellipsis">
                          White Paper（白皮书）

                        </span>

                      </a>
                    </li>

                    <li class="md-nav__item md-nav__item--nested">

                      <input
                        class="md-nav__toggle md-toggle md-toggle--indeterminate"
                        type="checkbox" id="__nav_9">

                      <label class="md-nav__link" for="__nav_9"
                        id="__nav_9_label" tabindex="0">

                        <span class="md-ellipsis">
                          Advanced（高级）

                        </span>

                        <span class="md-nav__icon md-icon"></span>
                      </label>

                      <nav class="md-nav" data-md-level="1"
                        aria-labelledby="__nav_9_label" aria-expanded="false">
                        <label class="md-nav__title" for="__nav_9">
                          <span class="md-nav__icon md-icon"></span>
                          Advanced
                        </label>
                        <ul class="md-nav__list" data-md-scrollfix>

                          <li class="md-nav__item">
                            <a href="../../internals/index.html"
                              class="md-nav__link">

                              <span class="md-ellipsis">
                                FlatBuffers Internals（内部结构）

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a
                              href="../../intermediate_representation/index.html"
                              class="md-nav__link">

                              <span class="md-ellipsis">
                                Intermediate Representation（中间表示）

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../../annotation/index.html"
                              class="md-nav__link">

                              <span class="md-ellipsis">
                                Annotating Buffers (.afb)

                              </span>

                            </a>
                          </li>

                          <li class="md-nav__item">
                            <a href="../../benchmarks/index.html"
                              class="md-nav__link">

                              <span class="md-ellipsis">
                                Benchmarks（基准测试）

                              </span>

                            </a>
                          </li>

                        </ul>
                      </nav>

                    </li>

                    <li class="md-nav__item">
                      <a href="../../flexbuffers/index.html"
                        class="md-nav__link">

                        <span class="md-ellipsis">
                          FlexBuffers (Schema-less version)（无模式版本）

                        </span>

                      </a>
                    </li>

                    <li class="md-nav__item">
                      <a href="../../contributing/index.html"
                        class="md-nav__link">

                        <span class="md-ellipsis">
                          Contributing（贡献）

                        </span>

                      </a>
                    </li>

                  </ul>
                </nav>
              </div>
            </div>
          </div>

          <div class="md-sidebar md-sidebar--secondary"
            data-md-component="sidebar" data-md-type="toc">
            <div class="md-sidebar__scrollwrap">
              <div class="md-sidebar__inner">

                <nav class="md-nav md-nav--secondary"
                  aria-label="Table of contents">

                  <label class="md-nav__title" for="__toc">
                    <span class="md-nav__icon md-icon"></span>
                    Table of contents
                  </label>
                  <ul class="md-nav__list" data-md-component="toc"
                    data-md-scrollfix>

                    <li class="md-nav__item">
                      <a href="#before-you-get-started" class="md-nav__link">
                        <span class="md-ellipsis">
                          Before you get started
                        </span>
                      </a>

                      <nav class="md-nav" aria-label="Before you get started">
                        <ul class="md-nav__list">

                          <li class="md-nav__item">
                            <a href="#prerequisites" class="md-nav__link">
                              <span class="md-ellipsis">
                                Prerequisites
                              </span>
                            </a>

                          </li>

                        </ul>
                      </nav>

                    </li>

                    <li class="md-nav__item">
                      <a href="#flatbuffers-c-library-code-location"
                        class="md-nav__link">
                        <span class="md-ellipsis">
                          FlatBuffers C++ library code location
                        </span>
                      </a>

                    </li>

                    <li class="md-nav__item">
                      <a href="#testing-the-flatbuffers-c-library"
                        class="md-nav__link">
                        <span class="md-ellipsis">
                          Testing the FlatBuffers C++ library
                        </span>
                      </a>

                    </li>

                    <li class="md-nav__item">
                      <a href="#using-the-flatbuffers-c-library"
                        class="md-nav__link">
                        <span class="md-ellipsis">
                          Using the FlatBuffers C++ library
                        </span>
                      </a>

                    </li>

                    <li class="md-nav__item">
                      <a href="#object-based-api" class="md-nav__link">
                        <span class="md-ellipsis">
                          Object based API
                        </span>
                      </a>

                    </li>

                    <li class="md-nav__item">
                      <a href="#external-references" class="md-nav__link">
                        <span class="md-ellipsis">
                          External references
                        </span>
                      </a>

                    </li>

                    <li class="md-nav__item">
                      <a href="#using-different-pointer-types"
                        class="md-nav__link">
                        <span class="md-ellipsis">
                          Using different pointer types
                        </span>
                      </a>

                    </li>

                    <li class="md-nav__item">
                      <a href="#using-different-string-type"
                        class="md-nav__link">
                        <span class="md-ellipsis">
                          Using different string type
                        </span>
                      </a>

                    </li>

                    <li class="md-nav__item">
                      <a href="#reflection-resizing" class="md-nav__link">
                        <span class="md-ellipsis">
                          Reflection (&amp; Resizing)
                        </span>
                      </a>

                    </li>

                    <li class="md-nav__item">
                      <a href="#mini-reflection" class="md-nav__link">
                        <span class="md-ellipsis">
                          Mini Reflection
                        </span>
                      </a>

                    </li>

                    <li class="md-nav__item">
                      <a href="#storing-maps-dictionaries-in-a-flatbuffer"
                        class="md-nav__link">
                        <span class="md-ellipsis">
                          Storing maps / dictionaries in a FlatBuffer
                        </span>
                      </a>

                    </li>

                    <li class="md-nav__item">
                      <a href="#direct-memory-access" class="md-nav__link">
                        <span class="md-ellipsis">
                          Direct memory access
                        </span>
                      </a>

                    </li>

                    <li class="md-nav__item">
                      <a href="#access-of-untrusted-buffers"
                        class="md-nav__link">
                        <span class="md-ellipsis">
                          Access of untrusted buffers
                        </span>
                      </a>

                    </li>

                    <li class="md-nav__item">
                      <a href="#text-schema-parsing" class="md-nav__link">
                        <span class="md-ellipsis">
                          Text &amp; schema parsing
                        </span>
                      </a>

                      <nav class="md-nav"
                        aria-label="Text &amp; schema parsing">
                        <ul class="md-nav__list">

                          <li class="md-nav__item">
                            <a href="#using-the-compiler-as-a-conversion-tool"
                              class="md-nav__link">
                              <span class="md-ellipsis">
                                Using the compiler as a conversion tool
                              </span>
                            </a>

                          </li>

                          <li class="md-nav__item">
                            <a
                              href="#making-your-program-capable-of-loading-text-directly"
                              class="md-nav__link">
                              <span class="md-ellipsis">
                                Making your program capable of loading text
                                directly
                              </span>
                            </a>

                          </li>

                        </ul>
                      </nav>

                    </li>

                    <li class="md-nav__item">
                      <a href="#threading" class="md-nav__link">
                        <span class="md-ellipsis">
                          Threading
                        </span>
                      </a>

                    </li>

                    <li class="md-nav__item">
                      <a href="#advanced-union-features" class="md-nav__link">
                        <span class="md-ellipsis">
                          Advanced union features
                        </span>
                      </a>

                    </li>

                    <li class="md-nav__item">
                      <a
                        href="#depth-limit-of-nested-objects-and-stack-overflow-control"
                        class="md-nav__link">
                        <span class="md-ellipsis">
                          Depth limit of nested objects and stack-overflow
                          control
                        </span>
                      </a>

                    </li>

                    <li class="md-nav__item">
                      <a href="#flatbuffers_locale_cpp" class="md-nav__link">
                        <span class="md-ellipsis">
                          Dependence from C-locale
                        </span>
                      </a>

                    </li>

                    <li class="md-nav__item">
                      <a href="#support-of-floating-point-numbers"
                        class="md-nav__link">
                        <span class="md-ellipsis">
                          Support of floating-point numbers
                        </span>
                      </a>

                      <nav class="md-nav"
                        aria-label="Support of floating-point numbers">
                        <ul class="md-nav__list">

                          <li class="md-nav__item">
                            <a
                              href="#support-of-hexadecimal-and-special-floating-point-numbers"
                              class="md-nav__link">
                              <span class="md-ellipsis">
                                Support of hexadecimal and special
                                floating-point numbers
                              </span>
                            </a>

                          </li>

                          <li class="md-nav__item">
                            <a href="#comparison-of-floating-point-nan-values"
                              class="md-nav__link">
                              <span class="md-ellipsis">
                                Comparison of floating-point NaN values
                              </span>
                            </a>

                          </li>

                        </ul>
                      </nav>

                    </li>

                    <li class="md-nav__item">
                      <a href="#grpc" class="md-nav__link">
                        <span class="md-ellipsis">
                          gRPC
                        </span>
                      </a>

                      <nav class="md-nav" aria-label="gRPC">
                        <ul class="md-nav__list">

                          <li class="md-nav__item">
                            <a href="#before-you-get-started_1"
                              class="md-nav__link">
                              <span class="md-ellipsis">
                                Before you get started
                              </span>
                            </a>

                          </li>

                          <li class="md-nav__item">
                            <a href="#using-the-flatbuffers-grpc-c-library"
                              class="md-nav__link">
                              <span class="md-ellipsis">
                                Using the FlatBuffers gRPC C++ library
                              </span>
                            </a>

                          </li>

                        </ul>
                      </nav>

                    </li>

                  </ul>

                </nav>
              </div>
            </div>
          </div>

          <div class="md-content" data-md-component="content">
            <article class="md-content__inner md-typeset">

              <a
                href="https://github.com/google/flatbuffers/edit/master/docs/source/languages/cpp.md"
                title="Edit this page" class="md-content__button md-icon">

                <svg xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 24 24"><path
                    d="M10 20H6V4h7v5h5v3.1l2-2V8l-6-6H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h4zm10.2-7c.1 0 .3.1.4.2l1.3 1.3c.2.2.2.6 0 .8l-1 1-2.1-2.1 1-1c.1-.1.2-.2.4-.2m0 3.9L14.1 23H12v-2.1l6.1-6.1z" /></svg>
              </a>

              <h1 id="language-guide-c">Language Guide: C++</h1>
              <h2 id="before-you-get-started">Before you get started</h2>
              <p>Before diving into the FlatBuffers usage in C++, it should be
                noted that
                the <a href="../../tutorial/index.html">Tutorial</a> page has a
                complete guide
                to general FlatBuffers usage in all of the supported languages
                (including C++).
                This page is designed to cover the nuances of FlatBuffers usage,
                specific to
                C++.</p>
              <h4 id="prerequisites">Prerequisites</h4>
              <p>This page assumes you have written a FlatBuffers schema and
                compiled it
                with the Schema Compiler. If you have not, please see
                <a href="../../flatc/index.html">Using the schema compiler</a>
                and <a href="../../schema/index.html">Writing a schema</a>.</p>
              <p>Assuming you wrote a schema, say <code>mygame.fbs</code>
                (though the extension doesn't
                matter), you've generated a C++ header called
                <code>mygame_generated.h</code> using the
                compiler (e.g. <code>flatc -c mygame.fbs</code>), you can now
                start using this in
                your program by including the header. As noted, this header
                relies on
                <code>flatbuffers/flatbuffers.h</code>, which should be in your
                include path.</p>
              <h2 id="flatbuffers-c-library-code-location">FlatBuffers C++
                library code location</h2>
              <p>The code for the FlatBuffers C++ library can be found at
                <code>flatbuffers/include/flatbuffers</code>. You can browse the
                library code on the
                <a
                  href="https://github.com/google/flatbuffers/tree/master/include/flatbuffers">FlatBuffers
                  GitHub page</a>.</p>
              <h2 id="testing-the-flatbuffers-c-library">Testing the FlatBuffers
                C++ library</h2>
              <p>The code to test the C++ library can be found at
                <code>flatbuffers/tests</code>.
                The test code itself is located in
                <a
                  href="https://github.com/google/flatbuffers/blob/master/tests/test.cpp">test.cpp</a>.</p>
              <p>This test file is built alongside <code>flatc</code>. To review
                how to build the project,
                please read the <a href="../../building/index.html">Building</a>
                documentation.</p>
              <p>To run the tests, execute <code>flattests</code> from the root
                <code>flatbuffers/</code> directory.
                For example, on <a
                  href="https://en.wikipedia.org/wiki/Linux">Linux</a>, you
                would simply
                run: <code>./flattests</code>.</p>
              <h2 id="using-the-flatbuffers-c-library">Using the FlatBuffers C++
                library</h2>
              <p><em>Note: See <a href="../../tutorial/index.html">Tutorial</a>
                  for a more in-depth
                  example of how to use FlatBuffers in C++.</em></p>
              <p>FlatBuffers supports both reading and writing FlatBuffers in
                C++.</p>
              <p>To use FlatBuffers in your code, first generate the C++ classes
                from your
                schema with the <code>--cpp</code> option to <code>flatc</code>.
                Then you can include both FlatBuffers
                and the generated code to read or write FlatBuffers.</p>
              <p>For example, here is how you would read a FlatBuffer binary
                file in C++:
                First, include the library and generated code. Then read the
                file into
                a <code>char *</code> array, which you pass to
                <code>GetMonster()</code>.</p>
              <div
                class="highlight"><pre><span></span><code><span class="w">    </span><span class="cp">#include</span><span class="w"> </span><span class="cpf">&quot;flatbuffers/flatbuffers.h&quot;</span>
<span class="w">    </span><span class="cp">#include</span><span class="w"> </span><span class="cpf">&quot;monster_test_generate.h&quot;</span>
<span class="w">    </span><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;iostream&gt;</span><span class="c1"> // C++ header file for printing</span>
<span class="w">    </span><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;fstream&gt;</span><span class="c1"> // C++ header file for file access</span>


<span class="w">    </span><span class="n">std</span><span class="o">::</span><span class="n">ifstream</span><span class="w"> </span><span class="n">infile</span><span class="p">;</span>
<span class="w">    </span><span class="n">infile</span><span class="p">.</span><span class="n">open</span><span class="p">(</span><span class="s">&quot;monsterdata_test.mon&quot;</span><span class="p">,</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">ios</span><span class="o">::</span><span class="n">binary</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">ios</span><span class="o">::</span><span class="n">in</span><span class="p">);</span>
<span class="w">    </span><span class="n">infile</span><span class="p">.</span><span class="n">seekg</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="n">std</span><span class="o">::</span><span class="n">ios</span><span class="o">::</span><span class="n">end</span><span class="p">);</span>
<span class="w">    </span><span class="kt">int</span><span class="w"> </span><span class="n">length</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">infile</span><span class="p">.</span><span class="n">tellg</span><span class="p">();</span>
<span class="w">    </span><span class="n">infile</span><span class="p">.</span><span class="n">seekg</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="n">std</span><span class="o">::</span><span class="n">ios</span><span class="o">::</span><span class="n">beg</span><span class="p">);</span>
<span class="w">    </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">data</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="k">new</span><span class="w"> </span><span class="kt">char</span><span class="p">[</span><span class="n">length</span><span class="p">];</span>
<span class="w">    </span><span class="n">infile</span><span class="p">.</span><span class="n">read</span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="w"> </span><span class="n">length</span><span class="p">);</span>
<span class="w">    </span><span class="n">infile</span><span class="p">.</span><span class="n">close</span><span class="p">();</span>

<span class="w">    </span><span class="k">auto</span><span class="w"> </span><span class="n">monster</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">GetMonster</span><span class="p">(</span><span class="n">data</span><span class="p">);</span>
</code></pre></div>
              <p><code>monster</code> is of type <code>Monster *</code>, and
                points to somewhere <em>inside</em> your
                buffer (root object pointers are not the same as
                <code>buffer_pointer</code> !).
                If you look in your generated header, you'll see it has
                convenient accessors for all fields, e.g. <code>hp()</code>,
                <code>mana()</code>, etc:</p>
              <div
                class="highlight"><pre><span></span><code><span class="w">    </span><span class="n">std</span><span class="o">::</span><span class="n">cout</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="s">&quot;hp : &quot;</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">monster</span><span class="o">-&gt;</span><span class="n">hp</span><span class="p">()</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span><span class="w">              </span><span class="c1">// &#39;80&#39;</span>
<span class="w">    </span><span class="n">std</span><span class="o">::</span><span class="n">cout</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="s">&quot;mana : &quot;</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">monster</span><span class="o">-&gt;</span><span class="n">mana</span><span class="p">()</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span><span class="w">          </span><span class="c1">// default value of &#39;150&#39;</span>
<span class="w">    </span><span class="n">std</span><span class="o">::</span><span class="n">cout</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="s">&quot;name : &quot;</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">monster</span><span class="o">-&gt;</span><span class="n">name</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">c_str</span><span class="p">()</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span><span class="w"> </span><span class="c1">// &quot;MyMonster&quot;</span>
</code></pre></div>
              <p><em>Note: That we never stored a <code>mana</code> value, so it
                  will return the default.</em></p>
              <p>The following attributes are supported:</p>
              <ul>
                <li>
                  <p><code>shared</code> (on a field): For string fields, this
                    enables the usage of string
                    pooling (i.e. <code>CreateSharedString</code>) as default
                    serialization behavior.</p>
                  <p>Specifically, <code>CreateXxxDirect</code> functions and
                    <code>Pack</code> functions for object
                    based API (see below) will use
                    <code>CreateSharedString</code> to create strings.</p>
                </li>
              </ul>
              <h2 id="object-based-api">Object based API</h2>
              <p>FlatBuffers is all about memory efficiency, which is why its
                base API is written
                around using as little as possible of it. This does make the API
                clumsier
                (requiring pre-order construction of all data, and making
                mutation harder).</p>
              <p>For times when efficiency is less important a more convenient
                object based API
                can be used (through <code>--gen-object-api</code>) that is able
                to unpack &amp; pack a
                FlatBuffer into objects and standard STL containers, allowing
                for convenient
                construction, access and mutation.</p>
              <p>To use:</p>
              <div
                class="highlight"><pre><span></span><code><span class="w">    </span><span class="c1">// Autogenerated class from table Monster.</span>
<span class="w">    </span><span class="n">MonsterT</span><span class="w"> </span><span class="n">monsterobj</span><span class="p">;</span>

<span class="w">    </span><span class="c1">// Deserialize from buffer into object.</span>
<span class="w">    </span><span class="n">GetMonster</span><span class="p">(</span><span class="n">flatbuffer</span><span class="p">)</span><span class="o">-&gt;</span><span class="n">UnPackTo</span><span class="p">(</span><span class="o">&amp;</span><span class="n">monsterobj</span><span class="p">);</span>

<span class="w">    </span><span class="c1">// Update object directly like a C++ class instance.</span>
<span class="w">    </span><span class="n">cout</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">monsterobj</span><span class="p">.</span><span class="n">name</span><span class="p">;</span><span class="w">  </span><span class="c1">// This is now a std::string!</span>
<span class="w">    </span><span class="n">monsterobj</span><span class="p">.</span><span class="n">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Bob&quot;</span><span class="p">;</span><span class="w">  </span><span class="c1">// Change the name.</span>

<span class="w">    </span><span class="c1">// Serialize into new flatbuffer.</span>
<span class="w">    </span><span class="n">FlatBufferBuilder</span><span class="w"> </span><span class="n">fbb</span><span class="p">;</span>
<span class="w">    </span><span class="n">fbb</span><span class="p">.</span><span class="n">Finish</span><span class="p">(</span><span class="n">Monster</span><span class="o">::</span><span class="n">Pack</span><span class="p">(</span><span class="n">fbb</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">monsterobj</span><span class="p">));</span>
</code></pre></div>
              <p>The following attributes are specific to the object-based API
                code generation:</p>
              <ul>
                <li>
                  <p><code>native_inline</code> (on a field): Because FlatBuffer
                    tables and structs are
                    optionally present in a given buffer, they are best
                    represented as pointers
                    (specifically std::unique_ptrs) in the native class since
                    they can be null.
                    This attribute changes the member declaration to use the
                    type directly
                    rather than wrapped in a unique_ptr.</p>
                </li>
                <li>
                  <p><code>native_default("value")</code> (on a field): For
                    members that are declared
                    "native_inline", the value specified with this attribute
                    will be included
                    verbatim in the class constructor initializer list for this
                    member.</p>
                </li>
                <li>
                  <p><code>native_custom_alloc("custom_allocator")</code> (on a
                    table or struct): When using the
                    object-based API all generated NativeTables that are
                    allocated when unpacking
                    your flatbuffer will use "custom allocator". The allocator
                    is also used by
                    any std::vector that appears in a table defined with
                    <code>native_custom_alloc</code>.
                    This can be used to provide allocation from a pool for
                    example, for faster
                    unpacking when using the object-based API.</p>
                </li>
              </ul>
              <p>Minimal Example:</p>
              <p>schema:</p>
              <div
                class="highlight"><pre><span></span><code><span class="w">    </span><span class="n">table</span><span class="w"> </span><span class="n">mytable</span><span class="p">(</span><span class="n">native_custom_alloc</span><span class="o">:</span><span class="s">&quot;custom_allocator&quot;</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">      </span><span class="p">...</span>
<span class="w">    </span><span class="p">}</span>
</code></pre></div>
              <p>with <code>custom_allocator</code> defined before
                <code>flatbuffers.h</code> is included, as:</p>
              <div
                class="highlight"><pre><span></span><code><span class="w">    </span><span class="k">template</span><span class="w"> </span><span class="o">&lt;</span><span class="k">typename</span><span class="w"> </span><span class="nc">T</span><span class="o">&gt;</span><span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">custom_allocator</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="k">public</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">allocator</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span>

<span class="w">      </span><span class="k">typedef</span><span class="w"> </span><span class="n">T</span><span class="w"> </span><span class="o">*</span><span class="n">pointer</span><span class="p">;</span>

<span class="w">      </span><span class="k">template</span><span class="w"> </span><span class="o">&lt;</span><span class="k">class</span><span class="w"> </span><span class="nc">U</span><span class="o">&gt;</span>
<span class="w">      </span><span class="k">struct</span><span class="w"> </span><span class="nc">rebind</span><span class="w"> </span><span class="p">{</span>
<span class="w">        </span><span class="k">typedef</span><span class="w"> </span><span class="n">custom_allocator</span><span class="o">&lt;</span><span class="n">U</span><span class="o">&gt;</span><span class="w"> </span><span class="n">other</span><span class="p">;</span>
<span class="w">      </span><span class="p">};</span>

<span class="w">      </span><span class="n">pointer</span><span class="w"> </span><span class="nf">allocate</span><span class="p">(</span><span class="k">const</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="kt">size_t</span><span class="w"> </span><span class="n">n</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">        </span><span class="k">return</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">allocator</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;::</span><span class="n">allocate</span><span class="p">(</span><span class="n">n</span><span class="p">);</span>
<span class="w">      </span><span class="p">}</span>

<span class="w">      </span><span class="kt">void</span><span class="w"> </span><span class="nf">deallocate</span><span class="p">(</span><span class="n">T</span><span class="o">*</span><span class="w"> </span><span class="n">ptr</span><span class="p">,</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="kt">size_t</span><span class="w"> </span><span class="n">n</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">        </span><span class="k">return</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">allocator</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;::</span><span class="n">deallocate</span><span class="p">(</span><span class="n">ptr</span><span class="p">,</span><span class="n">n</span><span class="p">);</span>
<span class="w">      </span><span class="p">}</span>

<span class="w">      </span><span class="n">custom_allocator</span><span class="p">()</span><span class="w"> </span><span class="k">throw</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span>

<span class="w">      </span><span class="k">template</span><span class="w"> </span><span class="o">&lt;</span><span class="k">class</span><span class="w"> </span><span class="nc">U</span><span class="o">&gt;</span>
<span class="w">      </span><span class="n">custom_allocator</span><span class="p">(</span><span class="k">const</span><span class="w"> </span><span class="n">custom_allocator</span><span class="o">&lt;</span><span class="n">U</span><span class="o">&gt;&amp;</span><span class="p">)</span><span class="w"> </span><span class="k">throw</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span>
<span class="w">    </span><span class="p">};</span>
</code></pre></div>
              <ul>
                <li><code>native_type("type")</code> (on a struct): In some
                  cases, a more optimal C++ data
                  type exists for a given struct. For example, the following
                  schema:</li>
              </ul>
              <div
                class="highlight"><pre><span></span><code><span class="w">    </span><span class="k">struct</span><span class="w"> </span><span class="nc">Vec2</span><span class="w"> </span><span class="p">{</span>
<span class="w">      </span><span class="nl">x</span><span class="p">:</span><span class="w"> </span><span class="kt">float</span><span class="p">;</span>
<span class="w">      </span><span class="nl">y</span><span class="p">:</span><span class="w"> </span><span class="kt">float</span><span class="p">;</span>
<span class="w">    </span><span class="p">}</span>
</code></pre></div>
              <p>generates the following Object-Based API class:</p>
              <div
                class="highlight"><pre><span></span><code><span class="w">    </span><span class="k">struct</span><span class="w"> </span><span class="nc">Vec2T</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">flatbuffers</span><span class="o">::</span><span class="n">NativeTable</span><span class="w"> </span><span class="p">{</span>
<span class="w">      </span><span class="kt">float</span><span class="w"> </span><span class="n">x</span><span class="p">;</span>
<span class="w">      </span><span class="kt">float</span><span class="w"> </span><span class="n">y</span><span class="p">;</span>
<span class="w">    </span><span class="p">};</span>
</code></pre></div>
              <p>However, it can be useful to instead use a user-defined C++
                type since it
                can provide more functionality, eg.</p>
              <div
                class="highlight"><pre><span></span><code><span class="w">    </span><span class="k">struct</span><span class="w"> </span><span class="nc">vector2</span><span class="w"> </span><span class="p">{</span>
<span class="w">      </span><span class="kt">float</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<span class="w">      </span><span class="n">vector2</span><span class="w"> </span><span class="k">operator</span><span class="o">+</span><span class="p">(</span><span class="n">vector2</span><span class="w"> </span><span class="n">rhs</span><span class="p">)</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">...</span><span class="w"> </span><span class="p">}</span>
<span class="w">      </span><span class="n">vector2</span><span class="w"> </span><span class="k">operator</span><span class="o">-</span><span class="p">(</span><span class="n">vector2</span><span class="w"> </span><span class="n">rhs</span><span class="p">)</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">...</span><span class="w"> </span><span class="p">}</span>
<span class="w">      </span><span class="kt">float</span><span class="w"> </span><span class="n">length</span><span class="p">()</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">...</span><span class="w"> </span><span class="p">}</span>
<span class="w">      </span><span class="c1">// etc.</span>
<span class="w">    </span><span class="p">};</span>
</code></pre></div>
              <p>The <code>native_type</code> attribute will replace the usage
                of the generated class
                with the given type. So, continuing with the example, the
                generated
                code would use <code>vector2</code> in place of
                <code>Vec2T</code> for all generated code of
                the Object-Based API.</p>
              <p>However, because the <code>native_type</code> is unknown to
                flatbuffers, the user must
                provide the following functions to aide in the serialization
                process:</p>
              <div
                class="highlight"><pre><span></span><code><span class="w">    </span><span class="k">namespace</span><span class="w"> </span><span class="nn">flatbuffers</span><span class="w"> </span><span class="p">{</span>
<span class="w">      </span><span class="n">Vec2</span><span class="w"> </span><span class="nf">Pack</span><span class="p">(</span><span class="k">const</span><span class="w"> </span><span class="n">vector2</span><span class="o">&amp;</span><span class="w"> </span><span class="n">obj</span><span class="p">);</span>
<span class="w">      </span><span class="n">vector2</span><span class="w"> </span><span class="nf">UnPack</span><span class="p">(</span><span class="k">const</span><span class="w"> </span><span class="n">Vec2</span><span class="o">&amp;</span><span class="w"> </span><span class="n">obj</span><span class="p">);</span>
<span class="w">    </span><span class="p">}</span>
</code></pre></div>
              <ul>
                <li><code>native_type_pack_name("name")</code> (on a struct when
                  <code>native_type</code> is
                  specified, too): when you want to use the same
                  <code>native_type</code> multiple times
                  (e. g. with different precision) you must make the names of
                  the Pack/UnPack
                  functions unique, otherwise you will run into compile errors.
                  This attribute
                  appends a name to the expected Pack/UnPack functions. So when
                  you
                  specify <code>native_type_pack_name("Vec2")</code> in the
                  above example you now need to
                  implement these serialization functions instead:</li>
              </ul>
              <div
                class="highlight"><pre><span></span><code><span class="w">    </span><span class="k">namespace</span><span class="w"> </span><span class="nn">flatbuffers</span><span class="w"> </span><span class="p">{</span>
<span class="w">      </span><span class="n">Vec2</span><span class="w"> </span><span class="nf">PackVec2</span><span class="p">(</span><span class="k">const</span><span class="w"> </span><span class="n">vector2</span><span class="o">&amp;</span><span class="w"> </span><span class="n">obj</span><span class="p">);</span>
<span class="w">      </span><span class="n">vector2</span><span class="w"> </span><span class="nf">UnPackVec2</span><span class="p">(</span><span class="k">const</span><span class="w"> </span><span class="n">Vec2</span><span class="o">&amp;</span><span class="w"> </span><span class="n">obj</span><span class="p">);</span>
<span class="w">    </span><span class="p">}</span>
</code></pre></div>
              <p>Finally, the following top-level attributes:</p>
              <ul>
                <li>
                  <p><code>native_include("path")</code> (at file level):
                    Because the <code>native_type</code> attribute
                    can be used to introduce types that are unknown to
                    flatbuffers, it may be
                    necessary to include "external" header files in the
                    generated code. This
                    attribute can be used to directly add an #include directive
                    to the top of
                    the generated code that includes the specified path
                    directly.</p>
                </li>
                <li>
                  <p><code>force_align</code>: this attribute may not be
                    respected in the object API,
                    depending on the aligned of the allocator used with
                    <code>new</code>.</p>
                </li>
              </ul>
              <h2 id="external-references">External references</h2>
              <p>An additional feature of the object API is the ability to allow
                you to load
                multiple independent FlatBuffers, and have them refer to
                eachothers objects
                using hashes which are then represented as typed pointers in the
                object API.</p>
              <p>To make this work have a field in the objects you want to
                referred to which is
                using the string hashing feature (see <code>hash</code>
                attribute in the
                <a href="../../schema/index.html">schema</a> documentation).
                Then you have
                a similar hash in the field referring to it, along with a
                <code>cpp_type</code>
                attribute specifying the C++ type this will refer to (this can
                be any C++
                type, and will get a <code>*</code> added).</p>
              <p>Then, in JSON or however you create these buffers, make sure
                they use the
                same string (or hash).</p>
              <p>When you call <code>UnPack</code> (or <code>Create</code>),
                you'll need a function that maps from
                hash to the object (see <code>resolver_function_t</code> for
                details).</p>
              <h2 id="using-different-pointer-types">Using different pointer
                types</h2>
              <p>By default the object tree is built out of
                <code>std::unique_ptr</code>, but you can
                influence this either globally (using the
                <code>--cpp-ptr-type</code> argument to
                <code>flatc</code>) or per field (using the
                <code>cpp_ptr_type</code> attribute) to by any smart
                pointer type (<code>my_ptr&lt;T&gt;</code>), or by specifying
                <code>naked</code> as the type to get <code>T *</code>
                pointers. Unlike the smart pointers, naked pointers do not
                manage memory for
                you, so you'll have to manage their lifecycles manually. To
                reference the
                pointer type specified by the <code>--cpp-ptr-type</code>
                argument to <code>flatc</code> from a
                flatbuffer field set the <code>cpp_ptr_type</code> attribute to
                <code>default_ptr_type</code>.</p>
              <h2 id="using-different-string-type">Using different string
                type</h2>
              <p>By default the object tree is built out of
                <code>std::string</code>, but you can
                influence this either globally (using the
                <code>--cpp-str-type</code> argument to
                <code>flatc</code>) or per field using the
                <code>cpp_str_type</code> attribute.</p>
              <p>The type must support <code>T::c_str()</code>,
                <code>T::length()</code> and <code>T::empty()</code> as member
                functions.</p>
              <p>Further, the type must be constructible from std::string, as by
                default a
                std::string instance is constructed and then used to initialize
                the custom
                string type. This behavior impedes efficient and zero-copy
                construction of
                custom string types; the <code>--cpp-str-flex-ctor</code>
                argument to <code>flatc</code> or the
                per field attribute <code>cpp_str_flex_ctor</code> can be used
                to change this behavior,
                so that the custom string type is constructed by passing the
                pointer and
                length of the FlatBuffers String. The custom string class will
                require a
                constructor in the following format:
                <code>custom_str_class(const char *, size_t)</code>.
                Please note that the character array is not guaranteed to be
                NULL terminated,
                you should always use the provided size to determine end of
                string.</p>
              <h2 id="reflection-resizing">Reflection (&amp; Resizing)</h2>
              <p>There is experimental support for reflection in FlatBuffers,
                allowing you to
                read and write data even if you don't know the exact format of a
                buffer, and
                even allows you to change sizes of strings and vectors
                in-place.</p>
              <p>The way this works is very elegant; there is actually a
                FlatBuffer schema that
                describes schemas (!) which you can find in
                <code>reflection/reflection.fbs</code>.
                The compiler, <code>flatc</code>, can write out any schemas it
                has just parsed as a binary
                FlatBuffer, corresponding to this meta-schema.</p>
              <p>Loading in one of these binary schemas at runtime allows you
                traverse any
                FlatBuffer data that corresponds to it without knowing the exact
                format. You
                can query what fields are present, and then read/write them
                after.</p>
              <p>For convenient field manipulation, you can include the header
                <code>flatbuffers/reflection.h</code> which includes both the
                generated code from the meta
                schema, as well as a lot of helper functions.</p>
              <p>And example of usage, for the time being, can be found in
                <code>test.cpp/ReflectionTest()</code>.</p>
              <h2 id="mini-reflection">Mini Reflection</h2>
              <p>A more limited form of reflection is available for direct
                inclusion in
                generated code, which doesn't do any (binary) schema access at
                all. It was designed
                to keep the overhead of reflection as low as possible (on the
                order of 2-6
                bytes per field added to your executable), but doesn't contain
                all the
                information the (binary) schema contains.</p>
              <p>You add this information to your generated code by specifying
                <code>--reflect-types</code>
                (or instead <code>--reflect-names</code> if you also want field
                / enum names).</p>
              <p>You can now use this information, for example to print a
                FlatBuffer to text:</p>
              <div
                class="highlight"><pre><span></span><code>auto s = flatbuffers::FlatBufferToString(flatbuf, MonsterTypeTable());
</code></pre></div>
              <p><code>MonsterTypeTable()</code> is declared in the generated
                code for each type. The
                string produced is very similar to the JSON produced by the
                <code>Parser</code> based
                text generator.</p>
              <p>You'll need <code>flatbuffers/minireflect.h</code> for this
                functionality. In there is also
                a convenient visitor/iterator so you can write your own output /
                functionality
                based on the mini reflection tables without having to know the
                FlatBuffers or
                reflection encoding.</p>
              <h2 id="storing-maps-dictionaries-in-a-flatbuffer">Storing maps /
                dictionaries in a FlatBuffer</h2>
              <p>FlatBuffers doesn't support maps natively, but there is support
                to
                emulate their behavior with vectors and binary search, which
                means you
                can have fast lookups directly from a FlatBuffer without having
                to unpack
                your data into a <code>std::map</code> or similar.</p>
              <p>To use it:
                - Designate one of the fields in a table as they "key" field.
                You do this
                by setting the <code>key</code> attribute on this field, e.g.
                <code>name:string (key)</code>.
                You may only have one key field, and it must be of string or
                scalar type.
                - Write out tables of this type as usual, collect their offsets
                in an
                array or vector.
                - Instead of <code>CreateVector</code>, call
                <code>CreateVectorOfSortedTables</code>,
                which will first sort all offsets such that the tables they
                refer to
                are sorted by the key field, then serialize it.
                - Now when you're accessing the FlatBuffer, you can use
                <code>Vector::LookupByKey</code>
                instead of just <code>Vector::Get</code> to access elements of
                the vector, e.g.:
                <code>myvector-&gt;LookupByKey("Fred")</code>, which returns a
                pointer to the
                corresponding table type, or <code>nullptr</code> if not found.
                <code>LookupByKey</code> performs a binary search, so should
                have a similar speed to
                <code>std::map</code>, though may be faster because of better
                caching. <code>LookupByKey</code>
                only works if the vector has been sorted, it will likely not
                find elements
                if it hasn't been sorted.</p>
              <h2 id="direct-memory-access">Direct memory access</h2>
              <p>As you can see from the above examples, all elements in a
                buffer are
                accessed through generated accessors. This is because everything
                is
                stored in little endian format on all platforms (the accessor
                performs a swap operation on big endian machines), and also
                because
                the layout of things is generally not known to the user.</p>
              <p>For structs, layout is deterministic and guaranteed to be the
                same
                across platforms (scalars are aligned to their
                own size, and structs themselves to their largest member), and
                you
                are allowed to access this memory directly by using
                <code>sizeof()</code> and
                <code>memcpy</code> on the pointer to a struct, or even an array
                of structs.</p>
              <p>To compute offsets to sub-elements of a struct, make sure they
                are a structs themselves, as then you can use the pointers to
                figure out the offset without having to hardcode it. This is
                handy for use of arrays of structs with calls like
                <code>glVertexAttribPointer</code>
                in OpenGL or similar APIs.</p>
              <p>It is important to note is that structs are still little endian
                on all
                machines, so only use tricks like this if you can guarantee
                you're not
                shipping on a big endian machine (an
                <code>assert(FLATBUFFERS_LITTLEENDIAN)</code>
                would be wise).</p>
              <h2 id="access-of-untrusted-buffers">Access of untrusted
                buffers</h2>
              <p>The generated accessor functions access fields over offsets,
                which is
                very quick. These offsets are not verified at run-time, so a
                malformed
                buffer could cause a program to crash by accessing random
                memory.</p>
              <p>When you're processing large amounts of data from a source you
                know (e.g.
                your own generated data on disk), this is acceptable, but when
                reading
                data from the network that can potentially have been modified by
                an
                attacker, this is undesirable.</p>
              <p>For this reason, you can optionally use a buffer verifier
                before you
                access the data. This verifier will check all offsets, all sizes
                of
                fields, and null termination of strings to ensure that when a
                buffer
                is accessed, all reads will end up inside the buffer.</p>
              <p>Each root type will have a verification function generated for
                it,
                e.g. for <code>Monster</code>, you can call:</p>
              <div
                class="highlight"><pre><span></span><code><span class="w">    </span><span class="kt">bool</span><span class="w"> </span><span class="n">ok</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">VerifyMonsterBuffer</span><span class="p">(</span><span class="n">Verifier</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="n">len</span><span class="p">));</span>
</code></pre></div>
              <p>if <code>ok</code> is true, the buffer is safe to read.</p>
              <p>Besides untrusted data, this function may be useful to call in
                debug
                mode, as extra insurance against data being corrupted somewhere
                along
                the way.</p>
              <p>While verifying a buffer isn't "free", it is typically faster
                than
                a full traversal (since any scalar data is not actually
                touched),
                and since it may cause the buffer to be brought into cache
                before
                reading, the actual overhead may be even lower than
                expected.</p>
              <p>In specialized cases where a denial of service attack is
                possible,
                the verifier has two additional constructor arguments that allow
                you to limit the nesting depth and total amount of tables the
                verifier may encounter before declaring the buffer malformed.
                The default is
                <code>Verifier(buf, len, 64 /* max depth */, 1000000, /* max
                  tables */)</code> which
                should be sufficient for most uses.</p>
              <h2 id="text-schema-parsing">Text &amp; schema parsing</h2>
              <p>Using binary buffers with the generated header provides a super
                low
                overhead use of FlatBuffer data. There are, however, times when
                you want
                to use text formats, for example because it interacts better
                with source
                control, or you want to give your users easy access to data.</p>
              <p>Another reason might be that you already have a lot of data in
                JSON
                format, or a tool that generates JSON, and if you can write a
                schema for
                it, this will provide you an easy way to use that data
                directly.</p>
              <p>(see the schema documentation for some specifics on the JSON
                format
                accepted).</p>
              <p>Schema evolution compatibility for the JSON format follows the
                same rules as the binary format (JSON formatted data will be
                forwards/backwards compatible with schemas that evolve in a
                compatible way).</p>
              <p>There are two ways to use text formats:</p>
              <h4 id="using-the-compiler-as-a-conversion-tool">Using the
                compiler as a conversion tool</h4>
              <p>This is the preferred path, as it doesn't require you to add
                any new
                code to your program, and is maximally efficient since you can
                ship with
                binary data. The disadvantage is that it is an extra step for
                your
                users/developers to perform, though you might be able to
                automate it.</p>
              <div
                class="highlight"><pre><span></span><code>flatc -b myschema.fbs mydata.json
</code></pre></div>
              <p>This will generate the binary file <code>mydata_wire.bin</code>
                which can be loaded
                as before.</p>
              <h4
                id="making-your-program-capable-of-loading-text-directly">Making
                your program capable of loading text directly</h4>
              <p>This gives you maximum flexibility. You could even opt to
                support both,
                i.e. check for both files, and regenerate the binary from text
                when
                required, otherwise just load the binary.</p>
              <p>This option is currently only available for C++, or Java
                through JNI.</p>
              <p>As mentioned in the section "Building" above, this technique
                requires
                you to link a few more files into your program, and you'll want
                to include
                <code>flatbuffers/idl.h</code>.</p>
              <p>Load text (either a schema or json) into an in-memory buffer
                (there is a
                convenient <code>LoadFile()</code> utility function in
                <code>flatbuffers/util.h</code> if you
                wish). Construct a parser:</p>
              <div
                class="highlight"><pre><span></span><code><span class="w">    </span><span class="n">flatbuffers</span><span class="o">::</span><span class="n">Parser</span><span class="w"> </span><span class="n">parser</span><span class="p">;</span>
</code></pre></div>
              <p>Now you can parse any number of text files in sequence:</p>
              <div
                class="highlight"><pre><span></span><code><span class="w">    </span><span class="n">parser</span><span class="p">.</span><span class="n">Parse</span><span class="p">(</span><span class="n">text_file</span><span class="p">.</span><span class="n">c_str</span><span class="p">());</span>
</code></pre></div>
              <p>This works similarly to how the command-line compiler works: a
                sequence
                of files parsed by the same <code>Parser</code> object allow
                later files to
                reference definitions in earlier files. Typically this means you
                first
                load a schema file (which populates <code>Parser</code> with
                definitions), followed
                by one or more JSON files.</p>
              <p>As optional argument to <code>Parse</code>, you may specify a
                null-terminated list of
                include paths. If not specified, any include statements try to
                resolve from
                the current directory.</p>
              <p>If there were any parsing errors, <code>Parse</code> will
                return <code>false</code>, and
                <code>Parser::error_</code> contains a human readable error
                string with a line number
                etc, which you should present to the creator of that file.</p>
              <p>After each JSON file, the <code>Parser::fbb</code> member
                variable is the
                <code>FlatBufferBuilder</code> that contains the binary buffer
                version of that
                file, that you can access as described above.</p>
              <p><code>samples/sample_text.cpp</code> is a code sample showing
                the above operations.</p>
              <h2 id="threading">Threading</h2>
              <p>Reading a FlatBuffer does not touch any memory outside the
                original buffer,
                and is entirely read-only (all const), so is safe to access from
                multiple
                threads even without synchronisation primitives.</p>
              <p>Creating a FlatBuffer is not thread safe. All state related to
                building
                a FlatBuffer is contained in a FlatBufferBuilder instance, and
                no memory
                outside of it is touched. To make this thread safe, either do
                not
                share instances of FlatBufferBuilder between threads
                (recommended), or
                manually wrap it in synchronisation primitives. There's no
                automatic way to
                accomplish this, by design, as we feel multithreaded
                construction
                of a single buffer will be rare, and synchronisation overhead
                would be costly.</p>
              <h2 id="advanced-union-features">Advanced union features</h2>
              <p>The C++ implementation currently supports vectors of unions
                (i.e. you can
                declare a field as <code>[T]</code> where <code>T</code> is a
                union type instead of a table type). It
                also supports structs and strings in unions, besides tables.</p>
              <p>For an example of these features, see
                <code>tests/union_vector</code>, and
                <code>UnionVectorTest</code> in <code>test.cpp</code>.</p>
              <p>Since these features haven't been ported to other languages
                yet, if you
                choose to use them, you won't be able to use these buffers in
                other languages
                (<code>flatc</code> will refuse to compile a schema that uses
                these features).</p>
              <p>These features reduce the amount of "table wrapping" that was
                previously
                needed to use unions.</p>
              <p>To use scalars, simply wrap them in a struct.</p>
              <h2
                id="depth-limit-of-nested-objects-and-stack-overflow-control">Depth
                limit of nested objects and stack-overflow control</h2>
              <p>The parser of Flatbuffers schema or json-files is kind of
                recursive parser.
                To avoid stack-overflow problem the parser has a built-in
                limiter of
                recursion depth. Number of nested declarations in a schema or
                number of
                nested json-objects is limited. By default, this depth limit set
                to <code>64</code>.
                It is possible to override this limit with
                <code>FLATBUFFERS_MAX_PARSING_DEPTH</code>
                definition. This definition can be helpful for testing purposes
                or embedded
                applications. For details see <a
                  href="../../building/index.html">build</a> of
                CMake-based projects.</p>
              <h2 id="flatbuffers_locale_cpp">Dependence from C-locale</h2>
              <p>The Flatbuffers <a href="../../grammar/index.html">grammar</a>
                uses ASCII
                character set for identifiers, alphanumeric literals, reserved
                words.</p>
              <p>Internal implementation of the Flatbuffers depends from
                functions which
                depend from C-locale: <code>strtod()</code> or
                <code>strtof()</code>, for example.
                The library expects the dot <code>.</code> symbol as the
                separator of an integer
                part from the fractional part of a float number.
                Another separator symbols (<code>,</code> for example) will
                break the compatibility
                and may lead to an error while parsing a Flatbuffers schema or a
                json file.</p>
              <p>The Standard C locale is a global resource, there is only one
                locale for
                the entire application. Some modern compilers and platforms have
                locale-independent or locale-narrow functions
                <code>strtof_l</code>, <code>strtod_l</code>,
                <code>strtoll_l</code>, <code>strtoull_l</code> to resolve this
                dependency.
                These functions use specified locale rather than the global or
                per-thread
                locale instead. They are part of POSIX-2008 but not part of the
                C/C++
                standard library, therefore, may be missing on some platforms.
                The Flatbuffers library try to detect these functions at
                configuration and
                compile time:
                - CMake <code>"CMakeLists.txt"</code>:
                - Check existence of <code>strtol_l</code> and
                <code>strtod_l</code> in the <code>&lt;stdlib.h&gt;</code>.
                - Compile-time <code>"/include/base.h"</code>:
                - <code>_MSC_VER &gt;= 1900</code>: MSVC2012 or higher if build
                with MSVC.
                - <code>_XOPEN_SOURCE&gt;=700</code>: POSIX-2008 if build with
                GCC/Clang.</p>
              <p>After detection, the definition
                <code>FLATBUFFERS_LOCALE_INDEPENDENT</code> will be
                set to <code>0</code> or <code>1</code>.
                To override or stop this detection use CMake
                <code>-DFLATBUFFERS_LOCALE_INDEPENDENT={0|1}</code>
                or predefine <code>FLATBUFFERS_LOCALE_INDEPENDENT</code>
                symbol.</p>
              <p>To test the compatibility of the Flatbuffers library with
                a specific locale use the environment variable
                <code>FLATBUFFERS_TEST_LOCALE</code>:
                <div
                  class="highlight"><pre><span></span><code>&gt;FLATBUFFERS_TEST_LOCALE<span class="o">=</span><span class="s2">&quot;&quot;</span><span class="w"> </span>./flattests
&gt;FLATBUFFERS_TEST_LOCALE<span class="o">=</span><span class="s2">&quot;ru_RU.CP1251&quot;</span><span class="w"> </span>./flattests
</code></pre></div></p>
              <h2 id="support-of-floating-point-numbers">Support of
                floating-point numbers</h2>
              <p>The Flatbuffers library assumes that a C++ compiler and a CPU
                are
                compatible with the <code>IEEE-754</code> floating-point
                standard.
                The schema and json parser may fail if <code>fast-math</code> or
                <code>/fp:fast</code> mode is active.</p>
              <h3
                id="support-of-hexadecimal-and-special-floating-point-numbers">Support
                of hexadecimal and special floating-point numbers</h3>
              <p>According to the <a href="../../grammar/index.html">grammar</a>
                <code>fbs</code> and <code>json</code> files
                may use hexadecimal and special (<code>NaN</code>,
                <code>Inf</code>) floating-point literals.
                The Flatbuffers uses <code>strtof</code> and <code>strtod</code>
                functions to parse floating-point
                literals. The Flatbuffers library has a code to detect a
                compiler compatibility
                with the literals. If necessary conditions are met the
                preprocessor constant
                <code>FLATBUFFERS_HAS_NEW_STRTOD</code> will be set to
                <code>1</code>.
                The support of floating-point literals will be limited at
                compile time
                if <code>FLATBUFFERS_HAS_NEW_STRTOD</code> constant is less than
                <code>1</code>.
                In this case, schemas with hexadecimal or special literals
                cannot be used.</p>
              <h3 id="comparison-of-floating-point-nan-values">Comparison of
                floating-point NaN values</h3>
              <p>The floating-point <code>NaN</code> (<code>not a number</code>)
                is special value which
                representing an undefined or unrepresentable value.
                <code>NaN</code> may be explicitly assigned to variables,
                typically as a representation
                for missing values or may be a result of a mathematical
                operation.
                The <code>IEEE-754</code> defines two kind of <code>NaNs</code>:
                - Quiet NaNs, or <code>qNaNs</code>.
                - Signaling NaNs, or <code>sNaNs</code>.</p>
              <p>According to the <code>IEEE-754</code>, a comparison with
                <code>NaN</code> always returns
                an unordered result even when compared with itself. As a result,
                a whole
                Flatbuffers object will be not equal to itself if has one or
                more <code>NaN</code>.
                Flatbuffers scalar fields that have the default value are not
                actually stored
                in the serialized data but are generated in code (see <a
                  href="../../schema/index.html">Writing a schema</a>).
                Scalar fields with <code>NaN</code> defaults break this
                behavior.
                If a schema has a lot of <code>NaN</code> defaults the
                Flatbuffers can override
                the unordered comparison by the ordered:
                <code>(NaN==NaN)-&gt;true</code>.
                This ordered comparison is enabled when compiling a program with
                the symbol
                <code>FLATBUFFERS_NAN_DEFAULTS</code> defined.
                Additional computations added by
                <code>FLATBUFFERS_NAN_DEFAULTS</code> are very cheap
                if GCC or Clang used. These compilers have a compile-time
                implementation
                of <code>isnan</code> checking which MSVC does not.</p>
              <h2 id="grpc">gRPC</h2>
              <h3 id="before-you-get-started_1">Before you get started</h3>
              <p>Before diving into the FlatBuffers gRPC usage in C++, you
                should already be
                familiar with the following:</p>
              <ul>
                <li>FlatBuffers as a serialization format</li>
                <li><a href="http://www.grpc.io/docs/">gRPC</a> usage</li>
              </ul>
              <h3 id="using-the-flatbuffers-grpc-c-library">Using the
                FlatBuffers gRPC C++ library</h3>
              <p>NOTE: The examples below are also in the
                <code>grpc/samples/greeter</code> directory.</p>
              <p>We will illustrate usage with the following schema:</p>
              <div class="highlight"><span
                  class="filename">grpc/samples/greeter/greeter.fbs</span><pre><span></span><code><span class="n">table</span><span class="w"> </span><span class="n">HelloReply</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="nl">message</span><span class="p">:</span><span class="n">string</span><span class="p">;</span>
<span class="p">}</span>

<span class="n">table</span><span class="w"> </span><span class="n">HelloRequest</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="nl">name</span><span class="p">:</span><span class="n">string</span><span class="p">;</span>
<span class="p">}</span>

<span class="n">table</span><span class="w"> </span><span class="n">ManyHellosRequest</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="nl">name</span><span class="p">:</span><span class="n">string</span><span class="p">;</span>
<span class="w">  </span><span class="nl">num_greetings</span><span class="p">:</span><span class="kt">int</span><span class="p">;</span>
<span class="p">}</span>

<span class="n">rpc_service</span><span class="w"> </span><span class="n">Greeter</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="n">SayHello</span><span class="p">(</span><span class="n">HelloRequest</span><span class="p">)</span><span class="o">:</span><span class="n">HelloReply</span><span class="p">;</span>
<span class="w">  </span><span class="n">SayManyHellos</span><span class="p">(</span><span class="n">ManyHellosRequest</span><span class="p">)</span><span class="o">:</span><span class="n">HelloReply</span><span class="w"> </span><span class="p">(</span><span class="n">streaming</span><span class="o">:</span><span class="w"> </span><span class="s">&quot;server&quot;</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div>
              <p>When we run <code>flatc</code>, we pass in the
                <code>--grpc</code> option and generage an additional
                <code>greeter.grpc.fb.h</code> and
                <code>greeter.grpc.fb.cc</code>.</p>
              <p>Example server code looks like this:</p>
              <div class="highlight"><span
                  class="filename">grpc/samples/greeter/server.cpp</span><pre><span></span><code><span class="cp">#include</span><span class="w"> </span><span class="cpf">&quot;greeter.grpc.fb.h&quot;</span>
<span class="cp">#include</span><span class="w"> </span><span class="cpf">&quot;greeter_generated.h&quot;</span>

<span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;grpcpp/grpcpp.h&gt;</span>

<span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;iostream&gt;</span>
<span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;memory&gt;</span>
<span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;string&gt;</span>

<span class="k">class</span><span class="w"> </span><span class="nc">GreeterServiceImpl</span><span class="w"> </span><span class="k">final</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="k">public</span><span class="w"> </span><span class="n">Greeter</span><span class="o">::</span><span class="n">Service</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="k">virtual</span><span class="w"> </span><span class="n">grpc</span><span class="o">::</span><span class="n">Status</span><span class="w"> </span><span class="nf">SayHello</span><span class="p">(</span>
<span class="w">      </span><span class="n">grpc</span><span class="o">::</span><span class="n">ServerContext</span><span class="w"> </span><span class="o">*</span><span class="n">context</span><span class="p">,</span>
<span class="w">      </span><span class="k">const</span><span class="w"> </span><span class="n">flatbuffers</span><span class="o">::</span><span class="n">grpc</span><span class="o">::</span><span class="n">Message</span><span class="o">&lt;</span><span class="n">HelloRequest</span><span class="o">&gt;</span><span class="w"> </span><span class="o">*</span><span class="n">request_msg</span><span class="p">,</span>
<span class="w">      </span><span class="n">flatbuffers</span><span class="o">::</span><span class="n">grpc</span><span class="o">::</span><span class="n">Message</span><span class="o">&lt;</span><span class="n">HelloReply</span><span class="o">&gt;</span><span class="w"> </span><span class="o">*</span><span class="n">response_msg</span><span class="p">)</span><span class="w"> </span><span class="k">override</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="n">flatbuffers</span><span class="o">::</span><span class="n">grpc</span><span class="o">::</span><span class="n">MessageBuilder</span><span class="w"> </span><span class="n">mb_</span><span class="p">;</span>

<span class="w">    </span><span class="c1">// We call GetRoot to &quot;parse&quot; the message. Verification is already</span>
<span class="w">    </span><span class="c1">// performed by default. See the notes below for more details.</span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">HelloRequest</span><span class="w"> </span><span class="o">*</span><span class="n">request</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">request_msg</span><span class="o">-&gt;</span><span class="n">GetRoot</span><span class="p">();</span>

<span class="w">    </span><span class="c1">// Fields are retrieved as usual with FlatBuffers</span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="w"> </span><span class="o">&amp;</span><span class="n">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">request</span><span class="o">-&gt;</span><span class="n">name</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">str</span><span class="p">();</span>

<span class="w">    </span><span class="c1">// `flatbuffers::grpc::MessageBuilder` is a `FlatBufferBuilder` with a</span>
<span class="w">    </span><span class="c1">// special allocator for efficient gRPC buffer transfer, but otherwise</span>
<span class="w">    </span><span class="c1">// usage is the same as usual.</span>
<span class="w">    </span><span class="k">auto</span><span class="w"> </span><span class="n">msg_offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">mb_</span><span class="p">.</span><span class="n">CreateString</span><span class="p">(</span><span class="s">&quot;Hello, &quot;</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">name</span><span class="p">);</span>
<span class="w">    </span><span class="k">auto</span><span class="w"> </span><span class="n">hello_offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">CreateHelloReply</span><span class="p">(</span><span class="n">mb_</span><span class="p">,</span><span class="w"> </span><span class="n">msg_offset</span><span class="p">);</span>
<span class="w">    </span><span class="n">mb_</span><span class="p">.</span><span class="n">Finish</span><span class="p">(</span><span class="n">hello_offset</span><span class="p">);</span>

<span class="w">    </span><span class="c1">// The `ReleaseMessage&lt;T&gt;()` function detaches the message from the</span>
<span class="w">    </span><span class="c1">// builder, so we can transfer the resopnse to gRPC while simultaneously</span>
<span class="w">    </span><span class="c1">// detaching that memory buffer from the builer.</span>
<span class="w">    </span><span class="o">*</span><span class="n">response_msg</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">mb_</span><span class="p">.</span><span class="n">ReleaseMessage</span><span class="o">&lt;</span><span class="n">HelloReply</span><span class="o">&gt;</span><span class="p">();</span>
<span class="w">    </span><span class="n">assert</span><span class="p">(</span><span class="n">response_msg</span><span class="o">-&gt;</span><span class="n">Verify</span><span class="p">());</span>

<span class="w">    </span><span class="c1">// Return an OK status.</span>
<span class="w">    </span><span class="k">return</span><span class="w"> </span><span class="n">grpc</span><span class="o">::</span><span class="n">Status</span><span class="o">::</span><span class="n">OK</span><span class="p">;</span>
<span class="w">  </span><span class="p">}</span>

<span class="w">  </span><span class="k">virtual</span><span class="w"> </span><span class="n">grpc</span><span class="o">::</span><span class="n">Status</span><span class="w"> </span><span class="nf">SayManyHellos</span><span class="p">(</span>
<span class="w">      </span><span class="n">grpc</span><span class="o">::</span><span class="n">ServerContext</span><span class="w"> </span><span class="o">*</span><span class="n">context</span><span class="p">,</span>
<span class="w">      </span><span class="k">const</span><span class="w"> </span><span class="n">flatbuffers</span><span class="o">::</span><span class="n">grpc</span><span class="o">::</span><span class="n">Message</span><span class="o">&lt;</span><span class="n">ManyHellosRequest</span><span class="o">&gt;</span><span class="w"> </span><span class="o">*</span><span class="n">request_msg</span><span class="p">,</span>
<span class="w">      </span><span class="n">grpc</span><span class="o">::</span><span class="n">ServerWriter</span><span class="o">&lt;</span><span class="n">flatbuffers</span><span class="o">::</span><span class="n">grpc</span><span class="o">::</span><span class="n">Message</span><span class="o">&lt;</span><span class="n">HelloReply</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="o">*</span><span class="n">writer</span><span class="p">)</span>
<span class="w">      </span><span class="k">override</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="c1">// The streaming usage below is simply a combination of standard gRPC</span>
<span class="w">    </span><span class="c1">// streaming with the FlatBuffers usage shown above.</span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">ManyHellosRequest</span><span class="w"> </span><span class="o">*</span><span class="n">request</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">request_msg</span><span class="o">-&gt;</span><span class="n">GetRoot</span><span class="p">();</span>
<span class="w">    </span><span class="k">const</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="w"> </span><span class="o">&amp;</span><span class="n">name</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">request</span><span class="o">-&gt;</span><span class="n">name</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">str</span><span class="p">();</span>
<span class="w">    </span><span class="kt">int</span><span class="w"> </span><span class="n">num_greetings</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">request</span><span class="o">-&gt;</span><span class="n">num_greetings</span><span class="p">();</span>

<span class="w">    </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">num_greetings</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">      </span><span class="k">auto</span><span class="w"> </span><span class="n">msg_offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">mb_</span><span class="p">.</span><span class="n">CreateString</span><span class="p">(</span><span class="s">&quot;Many hellos, &quot;</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">name</span><span class="p">);</span>
<span class="w">      </span><span class="k">auto</span><span class="w"> </span><span class="n">hello_offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">CreateHelloReply</span><span class="p">(</span><span class="n">mb_</span><span class="p">,</span><span class="w"> </span><span class="n">msg_offset</span><span class="p">);</span>
<span class="w">      </span><span class="n">mb_</span><span class="p">.</span><span class="n">Finish</span><span class="p">(</span><span class="n">hello_offset</span><span class="p">);</span>
<span class="w">      </span><span class="n">writer</span><span class="o">-&gt;</span><span class="n">Write</span><span class="p">(</span><span class="n">mb_</span><span class="p">.</span><span class="n">ReleaseMessage</span><span class="o">&lt;</span><span class="n">HelloReply</span><span class="o">&gt;</span><span class="p">());</span>
<span class="w">    </span><span class="p">}</span>

<span class="w">    </span><span class="k">return</span><span class="w"> </span><span class="n">grpc</span><span class="o">::</span><span class="n">Status</span><span class="o">::</span><span class="n">OK</span><span class="p">;</span>
<span class="w">  </span><span class="p">}</span>

<span class="w">  </span><span class="n">flatbuffers</span><span class="o">::</span><span class="n">grpc</span><span class="o">::</span><span class="n">MessageBuilder</span><span class="w"> </span><span class="n">mb_</span><span class="p">;</span>
<span class="p">};</span>

<span class="kt">void</span><span class="w"> </span><span class="nf">RunServer</span><span class="p">()</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="w"> </span><span class="n">server_address</span><span class="p">(</span><span class="s">&quot;0.0.0.0:50051&quot;</span><span class="p">);</span>
<span class="w">  </span><span class="n">GreeterServiceImpl</span><span class="w"> </span><span class="n">service</span><span class="p">;</span>

<span class="w">  </span><span class="n">grpc</span><span class="o">::</span><span class="n">ServerBuilder</span><span class="w"> </span><span class="n">builder</span><span class="p">;</span>
<span class="w">  </span><span class="n">builder</span><span class="p">.</span><span class="n">AddListeningPort</span><span class="p">(</span><span class="n">server_address</span><span class="p">,</span><span class="w"> </span><span class="n">grpc</span><span class="o">::</span><span class="n">InsecureServerCredentials</span><span class="p">());</span>
<span class="w">  </span><span class="n">builder</span><span class="p">.</span><span class="n">RegisterService</span><span class="p">(</span><span class="o">&amp;</span><span class="n">service</span><span class="p">);</span>
<span class="w">  </span><span class="n">std</span><span class="o">::</span><span class="n">unique_ptr</span><span class="o">&lt;</span><span class="n">grpc</span><span class="o">::</span><span class="n">Server</span><span class="o">&gt;</span><span class="w"> </span><span class="n">server</span><span class="p">(</span><span class="n">builder</span><span class="p">.</span><span class="n">BuildAndStart</span><span class="p">());</span>
<span class="w">  </span><span class="n">std</span><span class="o">::</span><span class="n">cerr</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="s">&quot;Server listening on &quot;</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">server_address</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>

<span class="w">  </span><span class="n">server</span><span class="o">-&gt;</span><span class="n">Wait</span><span class="p">();</span>
<span class="p">}</span>

<span class="kt">int</span><span class="w"> </span><span class="nf">main</span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">argc</span><span class="p">,</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">*</span><span class="n">argv</span><span class="p">[])</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="n">RunServer</span><span class="p">();</span>
<span class="w">  </span><span class="k">return</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div>
              <p>Example client code looks like this:</p>
              <div class="highlight"><span
                  class="filename">grpc/samples/greeter/client.cpp</span><pre><span></span><code><span class="cp">#include</span><span class="w"> </span><span class="cpf">&quot;greeter.grpc.fb.h&quot;</span>
<span class="cp">#include</span><span class="w"> </span><span class="cpf">&quot;greeter_generated.h&quot;</span>

<span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;grpcpp/grpcpp.h&gt;</span>

<span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;iostream&gt;</span>
<span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;memory&gt;</span>
<span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;string&gt;</span>

<span class="k">class</span><span class="w"> </span><span class="nc">GreeterClient</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">public</span><span class="o">:</span>
<span class="w">  </span><span class="n">GreeterClient</span><span class="p">(</span><span class="n">std</span><span class="o">::</span><span class="n">shared_ptr</span><span class="o">&lt;</span><span class="n">grpc</span><span class="o">::</span><span class="n">Channel</span><span class="o">&gt;</span><span class="w"> </span><span class="n">channel</span><span class="p">)</span>
<span class="w">    </span><span class="o">:</span><span class="w"> </span><span class="n">stub_</span><span class="p">(</span><span class="n">Greeter</span><span class="o">::</span><span class="n">NewStub</span><span class="p">(</span><span class="n">channel</span><span class="p">))</span><span class="w"> </span><span class="p">{}</span>

<span class="w">  </span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="w"> </span><span class="n">SayHello</span><span class="p">(</span><span class="k">const</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="w"> </span><span class="o">&amp;</span><span class="n">name</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="n">flatbuffers</span><span class="o">::</span><span class="n">grpc</span><span class="o">::</span><span class="n">MessageBuilder</span><span class="w"> </span><span class="n">mb</span><span class="p">;</span>
<span class="w">    </span><span class="k">auto</span><span class="w"> </span><span class="n">name_offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">mb</span><span class="p">.</span><span class="n">CreateString</span><span class="p">(</span><span class="n">name</span><span class="p">);</span>
<span class="w">    </span><span class="k">auto</span><span class="w"> </span><span class="n">request_offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">CreateHelloRequest</span><span class="p">(</span><span class="n">mb</span><span class="p">,</span><span class="w"> </span><span class="n">name_offset</span><span class="p">);</span>
<span class="w">    </span><span class="n">mb</span><span class="p">.</span><span class="n">Finish</span><span class="p">(</span><span class="n">request_offset</span><span class="p">);</span>
<span class="w">    </span><span class="k">auto</span><span class="w"> </span><span class="n">request_msg</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">mb</span><span class="p">.</span><span class="n">ReleaseMessage</span><span class="o">&lt;</span><span class="n">HelloRequest</span><span class="o">&gt;</span><span class="p">();</span>

<span class="w">    </span><span class="n">flatbuffers</span><span class="o">::</span><span class="n">grpc</span><span class="o">::</span><span class="n">Message</span><span class="o">&lt;</span><span class="n">HelloReply</span><span class="o">&gt;</span><span class="w"> </span><span class="n">response_msg</span><span class="p">;</span>

<span class="w">    </span><span class="n">grpc</span><span class="o">::</span><span class="n">ClientContext</span><span class="w"> </span><span class="n">context</span><span class="p">;</span>

<span class="w">    </span><span class="k">auto</span><span class="w"> </span><span class="n">status</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stub_</span><span class="o">-&gt;</span><span class="n">SayHello</span><span class="p">(</span><span class="o">&amp;</span><span class="n">context</span><span class="p">,</span><span class="w"> </span><span class="n">request_msg</span><span class="p">,</span><span class="w"> </span><span class="o">&amp;</span><span class="n">response_msg</span><span class="p">);</span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">status</span><span class="p">.</span><span class="n">ok</span><span class="p">())</span><span class="w"> </span><span class="p">{</span>
<span class="w">      </span><span class="k">const</span><span class="w"> </span><span class="n">HelloReply</span><span class="w"> </span><span class="o">*</span><span class="n">response</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">response_msg</span><span class="p">.</span><span class="n">GetRoot</span><span class="p">();</span>
<span class="w">      </span><span class="k">return</span><span class="w"> </span><span class="n">response</span><span class="o">-&gt;</span><span class="n">message</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">str</span><span class="p">();</span>
<span class="w">    </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span>
<span class="w">      </span><span class="n">std</span><span class="o">::</span><span class="n">cerr</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">status</span><span class="p">.</span><span class="n">error_code</span><span class="p">()</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="s">&quot;: &quot;</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">status</span><span class="p">.</span><span class="n">error_message</span><span class="p">()</span>
<span class="w">                </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
<span class="w">      </span><span class="k">return</span><span class="w"> </span><span class="s">&quot;RPC failed&quot;</span><span class="p">;</span>
<span class="w">    </span><span class="p">}</span>
<span class="w">  </span><span class="p">}</span>

<span class="w">  </span><span class="kt">void</span><span class="w"> </span><span class="n">SayManyHellos</span><span class="p">(</span><span class="k">const</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="w"> </span><span class="o">&amp;</span><span class="n">name</span><span class="p">,</span><span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">num_greetings</span><span class="p">,</span>
<span class="w">                     </span><span class="n">std</span><span class="o">::</span><span class="n">function</span><span class="o">&lt;</span><span class="kt">void</span><span class="p">(</span><span class="k">const</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="w"> </span><span class="o">&amp;</span><span class="p">)</span><span class="o">&gt;</span><span class="w"> </span><span class="n">callback</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="n">flatbuffers</span><span class="o">::</span><span class="n">grpc</span><span class="o">::</span><span class="n">MessageBuilder</span><span class="w"> </span><span class="n">mb</span><span class="p">;</span>
<span class="w">    </span><span class="k">auto</span><span class="w"> </span><span class="n">name_offset</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">mb</span><span class="p">.</span><span class="n">CreateString</span><span class="p">(</span><span class="n">name</span><span class="p">);</span>
<span class="w">    </span><span class="k">auto</span><span class="w"> </span><span class="n">request_offset</span><span class="w"> </span><span class="o">=</span>
<span class="w">        </span><span class="n">CreateManyHellosRequest</span><span class="p">(</span><span class="n">mb</span><span class="p">,</span><span class="w"> </span><span class="n">name_offset</span><span class="p">,</span><span class="w"> </span><span class="n">num_greetings</span><span class="p">);</span>
<span class="w">    </span><span class="n">mb</span><span class="p">.</span><span class="n">Finish</span><span class="p">(</span><span class="n">request_offset</span><span class="p">);</span>
<span class="w">    </span><span class="k">auto</span><span class="w"> </span><span class="n">request_msg</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">mb</span><span class="p">.</span><span class="n">ReleaseMessage</span><span class="o">&lt;</span><span class="n">ManyHellosRequest</span><span class="o">&gt;</span><span class="p">();</span>

<span class="w">    </span><span class="n">flatbuffers</span><span class="o">::</span><span class="n">grpc</span><span class="o">::</span><span class="n">Message</span><span class="o">&lt;</span><span class="n">HelloReply</span><span class="o">&gt;</span><span class="w"> </span><span class="n">response_msg</span><span class="p">;</span>

<span class="w">    </span><span class="n">grpc</span><span class="o">::</span><span class="n">ClientContext</span><span class="w"> </span><span class="n">context</span><span class="p">;</span>

<span class="w">    </span><span class="k">auto</span><span class="w"> </span><span class="n">stream</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stub_</span><span class="o">-&gt;</span><span class="n">SayManyHellos</span><span class="p">(</span><span class="o">&amp;</span><span class="n">context</span><span class="p">,</span><span class="w"> </span><span class="n">request_msg</span><span class="p">);</span>
<span class="w">    </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="n">stream</span><span class="o">-&gt;</span><span class="n">Read</span><span class="p">(</span><span class="o">&amp;</span><span class="n">response_msg</span><span class="p">))</span><span class="w"> </span><span class="p">{</span>
<span class="w">      </span><span class="k">const</span><span class="w"> </span><span class="n">HelloReply</span><span class="w"> </span><span class="o">*</span><span class="n">response</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">response_msg</span><span class="p">.</span><span class="n">GetRoot</span><span class="p">();</span>
<span class="w">      </span><span class="n">callback</span><span class="p">(</span><span class="n">response</span><span class="o">-&gt;</span><span class="n">message</span><span class="p">()</span><span class="o">-&gt;</span><span class="n">str</span><span class="p">());</span>
<span class="w">    </span><span class="p">}</span>
<span class="w">    </span><span class="k">auto</span><span class="w"> </span><span class="n">status</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stream</span><span class="o">-&gt;</span><span class="n">Finish</span><span class="p">();</span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="o">!</span><span class="n">status</span><span class="p">.</span><span class="n">ok</span><span class="p">())</span><span class="w"> </span><span class="p">{</span>
<span class="w">      </span><span class="n">std</span><span class="o">::</span><span class="n">cerr</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">status</span><span class="p">.</span><span class="n">error_code</span><span class="p">()</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="s">&quot;: &quot;</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">status</span><span class="p">.</span><span class="n">error_message</span><span class="p">()</span>
<span class="w">                </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
<span class="w">      </span><span class="n">callback</span><span class="p">(</span><span class="s">&quot;RPC failed&quot;</span><span class="p">);</span>
<span class="w">    </span><span class="p">}</span>
<span class="w">  </span><span class="p">}</span>

<span class="w"> </span><span class="k">private</span><span class="o">:</span>
<span class="w">  </span><span class="n">std</span><span class="o">::</span><span class="n">unique_ptr</span><span class="o">&lt;</span><span class="n">Greeter</span><span class="o">::</span><span class="n">Stub</span><span class="o">&gt;</span><span class="w"> </span><span class="n">stub_</span><span class="p">;</span>
<span class="p">};</span>

<span class="kt">int</span><span class="w"> </span><span class="nf">main</span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">argc</span><span class="p">,</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="o">**</span><span class="n">argv</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">  </span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="w"> </span><span class="n">server_address</span><span class="p">(</span><span class="s">&quot;localhost:50051&quot;</span><span class="p">);</span>

<span class="w">  </span><span class="k">auto</span><span class="w"> </span><span class="n">channel</span><span class="w"> </span><span class="o">=</span>
<span class="w">      </span><span class="n">grpc</span><span class="o">::</span><span class="n">CreateChannel</span><span class="p">(</span><span class="n">server_address</span><span class="p">,</span><span class="w"> </span><span class="n">grpc</span><span class="o">::</span><span class="n">InsecureChannelCredentials</span><span class="p">());</span>
<span class="w">  </span><span class="n">GreeterClient</span><span class="w"> </span><span class="n">greeter</span><span class="p">(</span><span class="n">channel</span><span class="p">);</span>

<span class="w">  </span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="w"> </span><span class="n">name</span><span class="p">(</span><span class="s">&quot;world&quot;</span><span class="p">);</span>

<span class="w">  </span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="w"> </span><span class="n">message</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">greeter</span><span class="p">.</span><span class="n">SayHello</span><span class="p">(</span><span class="n">name</span><span class="p">);</span>
<span class="w">  </span><span class="n">std</span><span class="o">::</span><span class="n">cerr</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="s">&quot;Greeter received: &quot;</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">message</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>

<span class="w">  </span><span class="kt">int</span><span class="w"> </span><span class="n">num_greetings</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">10</span><span class="p">;</span>
<span class="w">  </span><span class="n">greeter</span><span class="p">.</span><span class="n">SayManyHellos</span><span class="p">(</span><span class="n">name</span><span class="p">,</span><span class="w"> </span><span class="n">num_greetings</span><span class="p">,</span><span class="w"> </span><span class="p">[](</span><span class="k">const</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="w"> </span><span class="o">&amp;</span><span class="n">message</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="n">std</span><span class="o">::</span><span class="n">cerr</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="s">&quot;Greeter received: &quot;</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">message</span><span class="w"> </span><span class="o">&lt;&lt;</span><span class="w"> </span><span class="n">std</span><span class="o">::</span><span class="n">endl</span><span class="p">;</span>
<span class="w">  </span><span class="p">});</span>

<span class="w">  </span><span class="k">return</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div>

            </article>
          </div>

          <script>var tabs=__md_get("__tabs");if(Array.isArray(tabs))e:for(var set of document.querySelectorAll(".tabbed-set")){var labels=set.querySelector(".tabbed-labels");for(var tab of tabs)for(var label of labels.getElementsByTagName("label"))if(label.innerText.trim()===tab){var input=document.getElementById(label.htmlFor);input.checked=!0;continue e}}</script>

          <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
        </div>

      </main>

      <footer class="md-footer">

        <nav class="md-footer__inner md-grid" aria-label="Footer">

          <a href="../c/index.html"
            class="md-footer__link md-footer__link--prev"
            aria-label="Previous: C">
            <div class="md-footer__button md-icon">

              <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path
                  d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z" /></svg>
            </div>
            <div class="md-footer__title">
              <span class="md-footer__direction">
                Previous
              </span>
              <div class="md-ellipsis">
                C
              </div>
            </div>
          </a>

          <a href="../c_sharp/index.html"
            class="md-footer__link md-footer__link--next" aria-label="Next: C#">
            <div class="md-footer__title">
              <span class="md-footer__direction">
                Next
              </span>
              <div class="md-ellipsis">
                C#
              </div>
            </div>
            <div class="md-footer__button md-icon">

              <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path
                  d="M4 11v2h12l-5.5 5.5 1.42 1.42L19.84 12l-7.92-7.92L10.5 5.5 16 11z" /></svg>
            </div>
          </a>

        </nav>

        <div class="md-footer-meta md-typeset">
          <div class="md-footer-meta__inner md-grid">
            <div class="md-copyright">

              <div class="md-copyright__highlight">
                Copyright &copy; 2025 Google
              </div>

              Made with
              <a href="https://squidfunk.github.io/mkdocs-material/"
                target="_blank" rel="noopener">
                Material for MkDocs
              </a>

            </div>

            <div class="md-social">

              <a href="https://github.com/google/flatbuffers" target="_blank"
                rel="noopener" title="github.com" class="md-social__link">
                <svg xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 496 512"><!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path
                    d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6m-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3m44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9M244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8M97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1m-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7m32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1m-11.4-14.7c-1.6 1-1.6 3.6 0 5.9s4.3 3.3 5.6 2.3c1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2" /></svg>
              </a>

              <a href="https:///discord.gg/6qgKs3R" target="_blank"
                rel="noopener" title class="md-social__link">
                <svg xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 640 512"><!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path
                    d="M524.531 69.836a1.5 1.5 0 0 0-.764-.7A485 485 0 0 0 404.081 32.03a1.82 1.82 0 0 0-1.923.91 338 338 0 0 0-14.9 30.6 447.9 447.9 0 0 0-134.426 0 310 310 0 0 0-15.135-30.6 1.89 1.89 0 0 0-1.924-.91 483.7 483.7 0 0 0-119.688 37.107 1.7 1.7 0 0 0-.788.676C39.068 183.651 18.186 294.69 28.43 404.354a2.02 2.02 0 0 0 .765 1.375 487.7 487.7 0 0 0 146.825 74.189 1.9 1.9 0 0 0 2.063-.676A348 348 0 0 0 208.12 430.4a1.86 1.86 0 0 0-1.019-2.588 321 321 0 0 1-45.868-21.853 1.885 1.885 0 0 1-.185-3.126 251 251 0 0 0 9.109-7.137 1.82 1.82 0 0 1 1.9-.256c96.229 43.917 200.41 43.917 295.5 0a1.81 1.81 0 0 1 1.924.233 235 235 0 0 0 9.132 7.16 1.884 1.884 0 0 1-.162 3.126 301.4 301.4 0 0 1-45.89 21.83 1.875 1.875 0 0 0-1 2.611 391 391 0 0 0 30.014 48.815 1.86 1.86 0 0 0 2.063.7A486 486 0 0 0 610.7 405.729a1.88 1.88 0 0 0 .765-1.352c12.264-126.783-20.532-236.912-86.934-334.541M222.491 337.58c-28.972 0-52.844-26.587-52.844-59.239s23.409-59.241 52.844-59.241c29.665 0 53.306 26.82 52.843 59.239 0 32.654-23.41 59.241-52.843 59.241m195.38 0c-28.971 0-52.843-26.587-52.843-59.239s23.409-59.241 52.843-59.241c29.667 0 53.307 26.82 52.844 59.239 0 32.654-23.177 59.241-52.844 59.241" /></svg>
              </a>

              <a href="https://twitter.com/dbaileychess" target="_blank"
                rel="noopener" title="twitter.com" class="md-social__link">
                <svg xmlns="http://www.w3.org/2000/svg"
                  viewBox="0 0 512 512"><!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path
                    d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8l164.9-188.5L26.8 48h145.6l100.5 132.9zm-24.8 373.8h39.1L151.1 88h-42z" /></svg>
              </a>

            </div>

          </div>
        </div>
      </footer>

    </div>
    <div class="md-dialog" data-md-component="dialog">
      <div class="md-dialog__inner md-typeset"></div>
    </div>

    <script id="__config"
      type="application/json">{"base": "../..", "features": ["content.code.annotate", "content.tabs.link", "navigation.expand", "navigation.footer", "header.autohide", "content.action.edit"], "search": "../../assets/javascripts/workers/search.f8cc74c7.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script>

    <script src="../../assets/javascripts/bundle.c8b220af.min.js"></script>

  </body>

  <!-- Mirrored from flatbuffers.dev/languages/cpp/ by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 08 May 2025 07:01:35 GMT -->
</html>